{use master_page('admin/v_master')} 

{block content}
<?php 
$cu_group = $this->usergroup_manager->get($this->current_user()->usergroup_id);  
?>
<script>
$(document).ready(function(){   
	$('#type').change(function(){
		var v = $(this).val(); 
		<?
		$get_type = array_remove($_GET, 'type');
		$get_params = Array();
		foreach($_GET as $k=>$v)
		{
			$get_params[] = "$k=$v";
		}
		$get_params_str = implode('&',$get_params);
		?>
		var url = '<?=_U("guest_book/index?")?><?=$get_params_str?>&type=' + v;
		//alert(url);
		//window.open(url);
		window.location.href = url ;  
	}) ;

	$("#chkall").click(function(){
		var checked = $(this).attr("checked");
		$(".datatable tbody input[type=checkbox]").attr("checked",checked) ;  
	}) ; 
	
})
</script>
<div class="blank20" style="height:20px;"></div>
<form id = 'form1' action = '<?=$_SERVER['REQUEST_URI']?>' method='post'>
	<?php if($cu_group->permission("guest_book","edit")):?>
	<div style="padding-left:10px;">
		<input style="width:132px;height:38px;line-height:38px;color:white;background:url(images/btn_03.gif) left top no-repeat;border:none; text-align:center;
 			 cursor: pointer;" class="btn_c" type="button" value=" 添加留言 " 
 			 onclick="javascript:window.location.href='<?php echo _U("guest_book/edit?&class_id=").$this->input->get('class-id')?>'">
	</div>
	<?php endif;?>
	<div class="blank5" style="height:10px;"></div>
	<div id="tagscontent" class="right_box">
		<table class="datatable" >
			<thead>
				<tr>
					<th  width="40px">
						<input title="点击可全选本页的所有项目" type="checkbox" id="chkall">
					</th> 
					<th width="70px"><?=lang('guest_book_id')?></th>
					<th><?=lang('guest_book_title')?></th>
					<th><?=lang('guest_book_contacter')?></th>
					<th><?=lang('guest_book_contacter_phone')?></th>
					<th><?=lang('guest_book_contacter_mobilephone')?></th>
					<th><?=lang('guest_book_is_agreed')?></th>
					<th><?=lang('guest_book_create_time')?></th>
					<th width="100">操作</th>
				</tr>
			</thead>
			<tbody>
				<?php foreach($guest_books as $guest_book):?>
				<tr> 
					<td >
						<input type="checkbox" value="<?php echo $guest_book->id;?>"  name="ids[]">
					</td>
					<td align="center">{guest_book->id}</td> 
					<td align="left">{guest_book->title}</td> 
					<td align="center">{guest_book->contacter}</td> 
					<td align="center">{guest_book->contacter_phone}</td> 
					<td align="center">{guest_book->contacter_mobilephone}</td> 
					<td align="center"><?$yesno = lang('global_yesno');echo $yesno[$guest_book->is_agreed]?></td> 
					<td align="center">{guest_book->create_time}</td> 
					<td>
						<?php if($cu_group->permission("guest_book","edit")):?>
						<a class="edit" onmouseover="tooltip.show('编辑');" onmouseout="tooltip.hide();" href="<?=_U('guest_book/edit?id=')?>{guest_book->id}">
						</a> 
						<?php endif;?>
						<?php if($cu_group->permission("guest_book","agree")):?>
						<?if($guest_book->is_agreed==0):?>
						<a class="examine" onmouseover="tooltip.show('审核');" onmouseout="tooltip.hide();"  href="<?=_U('guest_book/agree?id=')?>{guest_book->id}">
						</a>
						<?endif?> 
						<?php endif;?>
						<?php if($cu_group->permission("guest_book","del")):?>
						<a class="delete" onmouseover="tooltip.show('删除');" onmouseout="tooltip.hide();" onclick="javascript:return confirm('确认删除');" href="<?=_U('guest_book/del/')?>{guest_book->id}">
						</a>
						<?php endif;?>
					</td>
				</tr>
				<?php endforeach;?>
				<tr>
					<td colspan='10' style="text-align:center">
						<? $this->load->view('admin/v_pager',$sp_config); ?>
					</td>
				</tr>
			</tbody>
		</table>
	</div>
<script>
$(document).ready(function(){
	$('#btn_delete').click(function(){
		var frm = $("#form1");
		frm.attr('action','<?php echo _U("guest_book/del");?>'); 
		frm.submit(); 
	});

	$('#btn_agree').click(function(){
		var frm = $("#form1");
		frm.attr('action','<?php echo _U("guest_book/agree");?>'); 
		frm.submit(); 
	});
});
</script>
	<div class="blank10" style="height:10px"></div>
	<input type="hidden" name="batch" value="">
	<?php if($cu_group->permission("guest_book","del")):?>
	<input class="btn_d" type="button" value=" 删除 " id="btn_delete">
	<?php endif;?>
	<?php if($cu_group->permission("guest_book","agree")):?>
	<input class="btn_d" type="button" value=" 审核 " id="btn_agree">
	<?php endif;?>
</form>
{end} 